<?php
/**
 * Description of Login
 *
 * @author gonzalo.orellano
 */
class Login extends CI_Controller{
    
    private $url;
    
    public function __construct() {
        parent::__construct();
        $this->url = "http://localhost/proyecto/proyecto/";
    }
    
    public function admin(){
        $nombre = $this->input->post('nombre');
        $pass = $this->input->post('pass');
        $redirect = $this->input->post('redirect');

        if($nombre == 'Gonza' && $pass == '1234'){
            $this->session->set_userdata(array("nombre"=>"Gonza"));
            header("Location: ".$this->url."index.php/".$redirect);
        }
        else{
            $data['error'] = "Nombre de usuario o contrasenia incorrecto";
            $this->twig->display("login.html",$data);
        }
    }

    public function unlogin(){
        $data['error'] = "Usuario deslogueado exitosamente";
        $this->session->unset_userdata("nombre");
        $this->twig->display("login.html",$data);
    }

    public function index(){
        $this->twig->display("login.html");
    }
}
?>
